require("../../assets/css/reset.css");
require("../../assets/css/normalize.css");
require("../../assets/css/basic.css");
require("../../assets/css/property.css");
// 底部导航
require("../../assets/css/navBo.less");
// 字体图标
require("../../assets/fonts/font_hxgcas9slkl/iconfont.css");
require("../../assets/fonts/data/font_4046969_uq86ingo52k/iconfont.css");
require("./sport.less");

const dom = require("../../assets/js/util.js");
const axiox = require("../../assets/js/axios.js");
const { default: axios } = require("axios");
document.addEventListener("DOMContentLoaded", function () {
  dom.navBo("sport");
  axiox.get("/api/train/courseList").then((res) => {
    let data = res.data.data;
    console.log(data);
    //  获取第一块数据
    let newCoure = data.shift();
    console.log(newCoure);
    // 渲染课程
    dom.$(".coureTit").textContent = newCoure.name;
    // 图片
    dom.$("#newCoureImg").src = axios.defaults.baseURL + newCoure.imgurl;
    // 文字
    dom.$(".coureTitCoun").textContent = newCoure.desc.slice(0, 25);
    // 跳转ID
    dom.$(".newCoure").href = "../sport_detail.html?id=" + newCoure.courseId;

    // 摘要
    let html = "";
    data.forEach((v) => {
      html += `<a href="../sport_detail.html?id=${v.courseId}" class="course">
      <img src="${axios.defaults.baseURL + v.imgurl}" alt="" />
      <h4>${v.name}</h4>
      <p>${v.desc.slice(0, 20)}</p>
    </a>`;
      console.log(html);
    });
    dom.$(".abstract").innerHTML = html;
  });
});
